package com.xmy.cultivate.service.impl;

import com.xmy.cultivate.entity.LeaveTeacherStudent;
import com.xmy.cultivate.mapper.LeaveTeacherStudentMapper;
import com.xmy.cultivate.service.ILeaveTeacherStudentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 离职老师带班的学生 服务实现类
 * </p>
 *
 * @author hpiggy
 * @since 2024-12-19
 */
@Service
public class LeaveTeacherStudentServiceImpl extends ServiceImpl<LeaveTeacherStudentMapper, LeaveTeacherStudent> implements ILeaveTeacherStudentService {
    @Autowired
    LeaveTeacherStudentMapper leaveTeacherStudentMapper;

    @Override
    public Boolean leaveTeacherStudent(Integer yearPart, Integer quarterNum, Integer type) {
        List<LeaveTeacherStudent> leaveTeacherStudents = leaveTeacherStudentMapper.leaveTeacherStudent(yearPart, quarterNum);
        for (LeaveTeacherStudent leaveTeacherStudent : leaveTeacherStudents) {
            leaveTeacherStudent.setType(type);
            leaveTeacherStudentMapper.insert(leaveTeacherStudent);
        }
        return true;
    }

    @Override
    public Boolean updNotAdjustedByPay(Integer yearPart, Integer quarterNum) {
        List<LeaveTeacherStudent> leaveTeacherStudents = leaveTeacherStudentMapper.getNotAdjustedByPay(yearPart, quarterNum);
        for (LeaveTeacherStudent leaveTeacherStudent : leaveTeacherStudents) {
            leaveTeacherStudent.setSchoolmasterId(leaveTeacherStudent.getGradeTeacherId());
            leaveTeacherStudentMapper.updateById(leaveTeacherStudent);
        }
        return true;
    }
}
